package com.fa7.trabalho.entidades;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "USUARIO")
public class Usuario implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 2337288119223639544L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID", nullable = false)
	private Integer id ;

	@Column(name = "USERNAME", unique = true, length = 10)
	private String username;
	
	@Column(name = "PASSWORD", length = 8)
	private String password;
	
	@Column(name = "enable", columnDefinition = "BOOLEAN")
    private boolean enable;
	
	@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	@JoinColumn(name = "ID_PERFIL")
	private Perfil perfil;
	
	@OneToMany(fetch = FetchType.EAGER, mappedBy = "usuario")
    private Set<UsuarioAutorizacao> usuarioAutorizacoes;
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public boolean isEnable() {
		return enable;
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	public Perfil getPerfil() {
		return perfil;
	}

	public void setPerfil(Perfil perfil) {
		this.perfil = perfil;
	}

	public Set<UsuarioAutorizacao> getUsuarioAutorizacoes() {
		return usuarioAutorizacoes;
	}

	public void setUsuarioAutorizacoes(Set<UsuarioAutorizacao> usuarioAutorizacoes) {
		this.usuarioAutorizacoes = usuarioAutorizacoes;
	}

}
